%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/js-reserved-keywords-as-columns"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 62, 63, 64, 65, 11<br />2: 8, 15, 21, 26, 29, 35<br />3: 12, 18, 24, 32, 38, 40<br />ᐳ: 17, 19, 23, 25, 31, 33, 37, 39<br />4: ConnectionItems[43]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 43<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 19<br /><br />ROOT PgSelectSingleᐸmaterialᐳ[19]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 25<br /><br />ROOT PgSelectSingleᐸmaterialᐳ[25]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 33<br /><br />ROOT PgSelectSingleᐸcropᐳ[33]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 39<br /><br />ROOT PgSelectSingleᐸcropᐳ[39]"):::bucket
    Bucket6("Bucket 6 (listItem)<br /><br />ROOT __Item{6}ᐸ40ᐳ[41]"):::bucket
    Bucket8("Bucket 8 (listItem)<br /><br />ROOT __Item{8}ᐸ43ᐳ[54]"):::bucket
    Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 55<br /><br />ROOT PgSelectSingle{8}ᐸmaterialᐳ[55]"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2 & Bucket3 & Bucket4 & Bucket5 & Bucket6
    Bucket1 --> Bucket8
    Bucket8 --> Bucket9

    %% plan dependencies
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    PgSelect15[["PgSelect[15∈0] ➊<br />ᐸmaterialᐳ<br />More deps:<br />- Constantᐸ'concrete'ᐳ[62]"]]:::plan
    Object11 --> PgSelect15
    PgSelect21[["PgSelect[21∈0] ➊<br />ᐸmaterialᐳ<br />More deps:<br />- Constantᐸ'spongy'ᐳ[63]"]]:::plan
    Object11 --> PgSelect21
    PgSelect29[["PgSelect[29∈0] ➊<br />ᐸcropᐳ<br />More deps:<br />- Constantᐸ1ᐳ[64]"]]:::plan
    Object11 --> PgSelect29
    PgSelect35[["PgSelect[35∈0] ➊<br />ᐸcropᐳ<br />More deps:<br />- Constantᐸ'corn'ᐳ[65]"]]:::plan
    Object11 --> PgSelect35
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸmaterialᐳ"]]:::plan
    Object11 --> PgSelect8
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgSelect8 --> Connection12
    First17{{"First[17∈0] ➊"}}:::plan
    PgSelectRows18[["PgSelectRows[18∈0] ➊"]]:::plan
    PgSelectRows18 --> First17
    PgSelect15 --> PgSelectRows18
    PgSelectSingle19{{"PgSelectSingle[19∈0] ➊<br />ᐸmaterialᐳ"}}:::plan
    First17 --> PgSelectSingle19
    First23{{"First[23∈0] ➊"}}:::plan
    PgSelectRows24[["PgSelectRows[24∈0] ➊"]]:::plan
    PgSelectRows24 --> First23
    PgSelect21 --> PgSelectRows24
    PgSelectSingle25{{"PgSelectSingle[25∈0] ➊<br />ᐸmaterialᐳ"}}:::plan
    First23 --> PgSelectSingle25
    PgSelect26[["PgSelect[26∈0] ➊<br />ᐸcropᐳ"]]:::plan
    Object11 --> PgSelect26
    First31{{"First[31∈0] ➊"}}:::plan
    PgSelectRows32[["PgSelectRows[32∈0] ➊"]]:::plan
    PgSelectRows32 --> First31
    PgSelect29 --> PgSelectRows32
    PgSelectSingle33{{"PgSelectSingle[33∈0] ➊<br />ᐸcropᐳ"}}:::plan
    First31 --> PgSelectSingle33
    First37{{"First[37∈0] ➊"}}:::plan
    PgSelectRows38[["PgSelectRows[38∈0] ➊"]]:::plan
    PgSelectRows38 --> First37
    PgSelect35 --> PgSelectRows38
    PgSelectSingle39{{"PgSelectSingle[39∈0] ➊<br />ᐸcropᐳ"}}:::plan
    First37 --> PgSelectSingle39
    PgSelectRows40[["PgSelectRows[40∈0] ➊"]]:::plan
    PgSelect26 --> PgSelectRows40
    ConnectionItems43[["ConnectionItems[43∈0] ➊"]]:::plan
    Connection12 --> ConnectionItems43
    PgClassExpression46{{"PgClassExpression[46∈2] ➊<br />ᐸ__material__.”class”ᐳ"}}:::plan
    PgSelectSingle19 --> PgClassExpression46
    PgClassExpression50{{"PgClassExpression[50∈2] ➊<br />ᐸ__material__.”id”ᐳ"}}:::plan
    PgClassExpression46 o--o PgClassExpression50
    PgClassExpression47{{"PgClassExpression[47∈3] ➊<br />ᐸ__material__.”class”ᐳ"}}:::plan
    PgSelectSingle25 --> PgClassExpression47
    PgClassExpression51{{"PgClassExpression[51∈3] ➊<br />ᐸ__material__.”id”ᐳ"}}:::plan
    PgClassExpression47 o--o PgClassExpression51
    PgClassExpression48{{"PgClassExpression[48∈4] ➊<br />ᐸ__crop__.”yield”ᐳ"}}:::plan
    PgSelectSingle33 --> PgClassExpression48
    PgClassExpression52{{"PgClassExpression[52∈4] ➊<br />ᐸ__crop__.”amount”ᐳ"}}:::plan
    PgClassExpression48 o--o PgClassExpression52
    PgClassExpression49{{"PgClassExpression[49∈5] ➊<br />ᐸ__crop__.”amount”ᐳ"}}:::plan
    PgSelectSingle39 --> PgClassExpression49
    PgClassExpression53{{"PgClassExpression[53∈5] ➊<br />ᐸ__crop__.”id”ᐳ"}}:::plan
    PgClassExpression49 o--o PgClassExpression53
    __Item41[/"__Item[41∈6]<br />ᐸ40ᐳ"\]:::itemplan
    PgSelectRows40 ==> __Item41
    PgSelectSingle42{{"PgSelectSingle[42∈6]<br />ᐸcropᐳ"}}:::plan
    __Item41 --> PgSelectSingle42
    PgClassExpression56{{"PgClassExpression[56∈6]<br />ᐸ__crop__.”id”ᐳ"}}:::plan
    PgSelectSingle42 --> PgClassExpression56
    PgClassExpression57{{"PgClassExpression[57∈6]<br />ᐸ__crop__.”amount”ᐳ"}}:::plan
    PgClassExpression56 o--o PgClassExpression57
    PgClassExpression58{{"PgClassExpression[58∈6]<br />ᐸ__crop__.”yield”ᐳ"}}:::plan
    PgClassExpression57 o--o PgClassExpression58
    __Item54[/"__Item[54∈8]<br />ᐸ43ᐳ"\]:::itemplan
    ConnectionItems43 ==> __Item54
    PgSelectSingle55{{"PgSelectSingle[55∈8]<br />ᐸmaterialᐳ"}}:::plan
    __Item54 --> PgSelectSingle55
    PgClassExpression59{{"PgClassExpression[59∈9]<br />ᐸ__material__.”valueOf”ᐳ"}}:::plan
    PgSelectSingle55 --> PgClassExpression59
    PgClassExpression60{{"PgClassExpression[60∈9]<br />ᐸ__material__.”class”ᐳ"}}:::plan
    PgClassExpression59 o--o PgClassExpression60
    PgClassExpression61{{"PgClassExpression[61∈9]<br />ᐸ__material__.”id”ᐳ"}}:::plan
    PgClassExpression60 o--o PgClassExpression61

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Connection12,PgSelect15,First17,PgSelectRows18,PgSelectSingle19,PgSelect21,First23,PgSelectRows24,PgSelectSingle25,PgSelect26,PgSelect29,First31,PgSelectRows32,PgSelectSingle33,PgSelect35,First37,PgSelectRows38,PgSelectSingle39,PgSelectRows40,ConnectionItems43 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression46,PgClassExpression50 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,PgClassExpression47,PgClassExpression51 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression48,PgClassExpression52 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression49,PgClassExpression53 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item41,PgSelectSingle42,PgClassExpression56,PgClassExpression57,PgClassExpression58 bucket6
    classDef bucket8 stroke:#dda0dd
    class Bucket8,__Item54,PgSelectSingle55 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression59,PgClassExpression60,PgClassExpression61 bucket9

